<template>
    <div>
        <div class="mainbox">
            <div class="existbox" v-show="bookshow">
                <div class="booknote">
                    <img :src="book.img">
                    <div>
                        <p class="bookname">{{ book.book }}</p>
                        <p class="noteauthor">{{ book.author }}</p>
                        <p class="cjtime">{{ booklist.length }}条笔记</p>
                    </div>
                </div>
                <ul class="xiangqing">
                    <li v-for="(item,index) in booklist" :key="index">
                        <p>{{ item.content }}</p>
                        <div class="biji">
                            <span>笔记：{{ item.title }}</span>
                            <div class="shanchu" @click="remove(index)">
                                <img src="https://cdn7.axureshop.com/demo/1182587/images/%E7%AC%94%E8%AE%B0%E8%AF%A6%E6%83%85/u5187.png" alt="">
                                <img src="https://cdn7.axureshop.com/demo/1182587/images/%E7%AC%94%E8%AE%B0%E8%AF%A6%E6%83%85/u5188.png" class="icon">
                            </div>
                        </div>
                        <div class="bian"></div>
                    </li>
                </ul>
            </div>
            <div class="notNote" v-show="!bookshow">
                <img src="https://cdn7.axureshop.com/demo/1182587/images/%E7%AC%94%E8%AE%B0%E8%AF%A6%E6%83%85/u5191.png" alt="">
                <p>暂无笔记</p>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'NoteDetails',

    data() {
        return {
            title: "",
            book:{},
            booklist:[],
            bookshow:true,
        };
    },

    mounted() {
        this.book=this.$route.query.msg;
        this.booklist=this.book.note
    },

    methods: {
        remove(index){
            this.booklist.splice(index,1)
        }
    },
    watch:{
        "booklist.length"(newval){
            if(newval>0){
                this.bookshow=true;
            }else{
                this.bookshow=false
            }
        }
    }
};
</script>

<style lang="less" scoped>
.mainbox {
    width: 100%;
    margin-top: 5rem;
    padding: 0 2rem;
    position: relative;
    .existbox {
        padding: 1rem 0;
        .booknote {
            width: 100%;
            height: 7rem;
            display: flex;

            img {
                width: 5.4rem;
                height: 100%;
                margin-right: 1rem;
            }

            .bookname {
                font-size: 1.4rem;
                color: #333333;
            }

            .noteauthor {
                color: #999999;
                font-size: 1.2rem;
                line-height: 2.4rem;
            }

            .cjtime {
                color: #999999;
                font-size: 1.2rem;
                margin-top: 1rem;
            }
        }
        .xiangqing{
            li{
                padding: 0 1rem;
                background-color: #f9f9f9;
                border-radius: 0.5rem;
                color: #666666;
                font-size: 1.2rem;
                margin-bottom: 1rem;
                position: relative;
                .bian{
                    position: absolute;
                    left: 0;
                    top: 2rem;
                    width: 0.5rem;
                    height: 2.2rem;
                    background-color: #28d094;
                }
                p{
                    padding: 1rem 0;
                }
                .biji{
                    color: #28d094;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    height: 2.6rem;
                    border-top: 0.1rem solid #e5e5e5;
                    .shanchu{
                        width: 1.3rem;
                        height: 1.3rem;
                        position: relative;
                        img{
                            width: 100%;
                            height: 100%;

                        }
                        .icon{
                            width: 0.4rem;
                            height: 0.7rem;
                            position: absolute;
                            top: 55%;
                            left: 50%;
                            transform: translate(-50%,-50%);
                        }
                    }
                }
            }
        }
    }
    .notNote{
        position:fixed;
        width: 100%;
        top: 50%;
        left: 0;
        transform: translateY(-50%);
        text-align: center;
        color: #1E1E1E;
        font-size: 1.6rem;
        line-height: 3rem;
        img{
            width: 23.8rem;
            height: 20.3rem;
        }
    }
}
</style>